//
//  HitMusicTableViewCell.m
//  阿里星球-音乐界面
//
//  Created by mafeng on 16/8/14.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import "HitMusicTableViewCell.h"
#import "HitMusicCollectionViewCell.h"

@interface HitMusicTableViewCell ()<UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, strong) UICollectionViewFlowLayout *layout;
@property (nonatomic, strong) UICollectionView *collectionView;
@end

@implementation HitMusicTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.layout = [[UICollectionViewFlowLayout alloc] init];
        _collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:_layout];
        _collectionView.delegate = self;
        _collectionView.dataSource = self;
        [_collectionView registerNib:[UINib nibWithNibName:NSStringFromClass([HitMusicCollectionViewCell class]) bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"hitMusicReuse"];
        [self.contentView addSubview:_collectionView];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    _collectionView.frame = self.bounds;
    _layout.itemSize = CGSizeMake(self.bounds.size.width / 2.4, 120);
}

// collectionView的协议方法
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 2;
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HitMusicCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"hitMusicReuse" forIndexPath:indexPath];
    NSLog(@"🐷%@", _data.data);
   // cell.smallData = _data.data[indexPath.row];
    return cell;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
